package com.model
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import mx.collections.ArrayCollection;
	
	[Event(name="bookChanged", type="flash.events.Event")]
	
	public class Model extends EventDispatcher
	{
		private static var _instance:Model = new Model();
		
		
		public var manager:ModelManager = null;
		
		private var _currentBook:Book_VO = null;
		private var _books:ArrayCollection = null;
		
		public static function getIntstance():Model	{
			if(_instance.manager == null) {
				_instance.manager = new ModelManager(_instance);
			}
			return _instance;
		}
		
		[Bindable]
		public function get currentBook():Book_VO {
			return _currentBook;
		}
		public function set currentBook(value:Book_VO):void {
			if(_currentBook == value) {
				return;
			} 
			if(_currentBook) {
				_currentBook.freePages();
			}
			_currentBook = value;
			_currentBook.setupBook();
			dispatchEvent(new Event("bookChanged"));
		}
		
		public function get books():ArrayCollection {
			return _books;
		}
		public function set books(value:ArrayCollection):void {
			_books = value;
		}
		
	}
}